const MongoClient = require('mongodb').MongoClient
const fs=require('fs');

const uri= 'mongodb://192.168.1.60:27017';
const dbName='testCount';

MongoClient.connect(uri,{useUnifiedTopology:true},
    (err,client)=>{
        if(err){
            console.error(err)
            return;
        }
        const db=client.db(dbName);
        const collection=db.collection('files');
        const fileData =fs.readFileSync('/path/to/file.txt','utf8');
        const fileDocument ={name:'newFile',content:fileData};
        collection.insertOne(fileDocument,(err,result)=>{
            if(err){
                console.error(err);
            }else{
                console.log('File imported successfully');
            }
            client.close();
        });
    });